package net.ericaro.neojavagen;

import java.util.ArrayList;
import java.util.Arrays;

public class JavaPartList<P> extends ArrayList<P> {

	protected String dividerSymbol;
	protected String endSymbol;
	protected String startSymbol;

	public JavaPartList(String dividerSymbol, String startSymbol, String endSymbol, P... parts) {
		super();
		this.dividerSymbol = dividerSymbol;
		this.startSymbol = startSymbol;
		this.endSymbol = endSymbol;
		addAll(parts);
	}

	public void addAll(P... parts) {
		addAll(Arrays.asList(parts));

	}

	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		if (startSymbol != null)
			sb.append(startSymbol);
		StringUtils.join(dividerSymbol, this, sb);
		if (endSymbol != null)
			sb.append(endSymbol);
		return sb.toString();
	}
}
